package yi.Note.data.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created with IntelliJ IDEA.
 * User: b251
 * Date: 13-12-7
 * Time: 下午7:49
 * To change this template use File | Settings | File Templates.
 */
public class NoteProviderHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "yi.db";
    private static final int DATABASE_VERSION = 1;

    public NoteProviderHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        createTable(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
    private void createTable(SQLiteDatabase db) {
        db.execSQL("PRAGMA foreign_keys = ON;");
        // borqs_card_profile
        db.execSQL("CREATE TABLE " + NoteContent.TABLE_NOTE + " (" + NoteContent.Note._ID
                + " INTEGER PRIMARY KEY," + NoteContent.Note.TITLE + " TEXT," + NoteContent.Note.TEXT
                + " TEXT," + NoteContent.Note.TIMESTAMP + " INTEGER," + NoteContent.Note.REMINDER + " INTEGER);");

        db.execSQL("CREATE TABLE " + NoteContent.TABLE_ATT + " (" + NoteContent.Attachment._ID
                + " INTEGER PRIMARY KEY," + NoteContent.Attachment.TYPE + " TEXT,"
                + NoteContent.Attachment.URI + " TEXT,"
                + NoteContent.Attachment.NOTE_ID + " INTEGER,"
                + NoteContent.Attachment.SIZE + " INTEGER,"
                + " FOREIGN KEY(" + NoteContent.Attachment.NOTE_ID + ") REFERENCES " + NoteContent.TABLE_NOTE
                + "(" + NoteContent.Note._ID + "));");
    }
}
